/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hhf.logger;

import javax.ejb.EJB;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
import org.slf4j.MDC;

/**
 *
 * @author François
 */
public class MDCInterceptor {
	@EJB
	private MDCInitializer mdci;
	@AroundInvoke
	protected Object executing(InvocationContext ic) throws Exception {
		String deep = mdci.computeMDC(ic.getTarget().getClass(), ic.getMethod());
		try {
			return ic.proceed();
		} finally {
			MDC.put("deep", deep);
		}
	}
}
